\chapter{Singular cohomology}
\label{ch:singular_cohomology}
Here's one way to motivate this chapter. It turns out that:
\begin{itemize}
	\ii $H_n(\CP^2) \cong H_n(S^2 \vee S^4)$ for every $n$.
	\ii $H_n(\CP^3) \cong H_n(S^2 \times S^4)$ for every $n$.
\end{itemize}
This is unfortunate, because if possible we would like
to be able to tell these spaces apart (as they are
in fact not homotopy equivalent), but the homology groups
cannot tell the difference between them.

In this chapter, we'll define a \emph{cohomology group} $H^n(X)$ and $H^n(Y)$.
In fact, the $H^n$'s are completely determined by the $H_n$'s
by the so-called \emph{universal coefficient theorem}.
However, it turns out that one can take all the cohomology groups and put
them together to form a \emph{cohomology ring} $H^\bullet$.%
\footnote{\cite{ref:hatcher} has an explanation why is it that cohomology has more structures than
homology --- roughly speaking, the natural maps $X \times X \to X$ must be a projection which is not
very interesting, but there is a more interesting natural map $X \to X \times X$ given by $p \mapsto
(p, p)$.}
We will then see that $H^\bullet(X) \not\cong H^\bullet(Y)$ as rings.

\section{Cochain complexes}
\begin{definition}
A \vocab{cochain complex} $A^\bullet$ is algebraically the same as a chain complex,
except that the indices increase.
So it is a sequence of abelian groups
\[ \dots \taking{\delta} A^{n-1} \taking\delta A^n \taking\delta A^{n+1} \taking\delta \dots. \]
such that $\delta^2 = 0$.
Notation-wise, we're now using superscripts, and use $\delta$ rather $\partial$.
We define the \vocab{cohomology groups} by
\[ H^n(A^\bullet) = \ker\left( A^n \taking\delta A^{n+1} \right)
	/ \img\left( A^{n-1} \taking\delta A^n \right). \]
\end{definition}

\begin{example}[de Rham cohomology]
	We have already met one example of a cochain complex:
	let $M$ be a smooth manifold and $\Omega^k(M)$ be the
	additive group of $k$-forms on $M$.
	Then we have a cochain complex
	\[ 0 \taking d \Omega^0(M)
		\taking d \Omega^1(M) \taking d \Omega^2(M)
		\taking d \dots. \]
	The resulting cohomology is called \vocab{de Rham cohomology},
	described later.
\end{example}

Aside from de Rham's cochain complex,
\textbf{the most common way to get a cochain complex
is to \emph{dualize} a chain complex.}
Specifically, pick an abelian group $G$;
note that $\Hom(-, G)$ is a contravariant functor,
and thus takes every chain complex
\[ \dots \taking\partial A_{n+1} \taking\partial
	A_n \taking\partial A_{n-1} \taking\partial \dots \]
into a cochain complex: letting $A^n = \Hom(A_n, G)$ we obtain
\[ \dots \taking\delta A^{n-1} \taking\delta
	A^n \taking\delta A^{n+1} \taking\delta \dots. \]
where $\delta(A_n \taking{f} G) = A_{n+1} \taking\partial A \taking{f} G$.

These are the cohomology groups we study most in algebraic topology,
so we give a special notation to them.
\begin{definition}
	Given a chain complex $A_\bullet$ of abelian groups and another group $G$,
	we let \[ H^n(A_\bullet; G) \] denote the cohomology groups
	of the dual cochain complex $A^\bullet$ obtained by applying $\Hom(-,G)$.
	In other words, $H^n(A_\bullet; G) = H^n(A^\bullet)$.
\end{definition}

\section{Cohomology of spaces}
\prototype{$C^0(X;G)$ all functions $X \to G$ while $H^0(X)$ are those functions $X \to G$
constant on path components.}

The case of interest is our usual geometric situation, with $C_\bullet(X)$.
\begin{definition}
	For a space $X$ and abelian group $G$,
	we define $C^\bullet(X;G)$ to be the dual to the
	singular chain complex $C_\bullet(X)$,
	called the \vocab{singular cochain complex} of $X$;
	its elements are called \vocab{cochains}.

	Then we define the \vocab{cohomology groups}
	of the space $X$ as
	\[ H^n(X; G) \defeq H^n(C_\bullet(X); G) = H^n(C^\bullet(X;G)). \]
\end{definition}
\begin{remark}
	Note that if $G$ is also a ring (like $\ZZ$ or $\RR$),
	then $H^n(X; G)$ is not only an abelian group but actually a $G$-module.
\end{remark}

\begin{example}
	[$C^0(X; G)$, $C^1(X; G)$, and $H^0(X;G)$]
	Let $X$ be a topological space and consider $C^\bullet(X)$.
	\begin{itemize}
		\ii $C_0(X)$ is the free abelian group on $X$,
		and $C^0(X) = \Hom(C_0(X), G)$.
		So a $0$-cochain is a function that
		takes every point of $X$ to an element of $G$.
		\ii $C_1(X)$ is the free abelian group on $1$-simplices in $X$.
		So $C^1(X)$ needs to take every $1$-simplex to an element of $G$.
	\end{itemize}
	Let's now try to understand $\delta \colon C^0(X) \to C^1(X)$.
	Given a $0$-cochain $\phi \in C^0(X)$,
	i.e.\ a homomorphism $\phi \colon C^0(X) \to G$,
	what is $\delta\phi \colon C^1(X) \to G$?
	Answer:
	\[ \delta\phi \colon [v_0, v_1] \mapsto \phi([v_0]) - \phi([v_1]). \]
	Hence, elements of
	$\ker(C^0 \taking\delta C^1) \cong H^0(X;G)$
	are those cochains
	that are \emph{constant on path-connected components}.
\end{example}
In particular, much like $H_0(X)$, we have \[ H^0(X) \cong G^{\oplus r} \]
if $X$ has $r$ path-connected components (where $r$ is finite\footnote{%
	Something funny happens if $X$ has \emph{infinitely} many path-connected components:
	say $X = \coprod_\alpha X_\alpha$ over an infinite indexing set.
	In this case we have
	$H_0(X) = \bigoplus_\alpha G$ while $H^0(X) = \prod_\alpha G$.
	For homology we get a \emph{direct sum} while
	for cohomology we get a \emph{direct product}.

	These are actually different for infinite indexing sets.
	For general modules $\bigoplus_\alpha M_\alpha$ is \emph{defined} to only allow
	to have \emph{finitely many} nonzero terms.
	(This was never mentioned earlier in the Napkin,
	since I only ever defined $M \oplus N$ and extended it to finite direct sums.)
	No such restriction holds for $\prod_\alpha G_\alpha$ a product of groups.
	This corresponds to the fact that $C_0(X)$ is formal linear sums of $0$-chains
	(which, like all formal sums, are finite)
	from the path-connected components of $G$.
	But a cochain of $C^0(X)$ is a \emph{function}
	from each path-connected component of $X$ to $G$,
	where there is no restriction.
}).

\begin{abuse}
	In this chapter the only cochain complexes
	we will consider are dual complexes as above.
	So, any time we write a cochain complex $A^\bullet$ it is implicitly given
	by applying $\Hom(-,G)$ to $A_\bullet$.
\end{abuse}

The higher cohomology groups $H^n(X; G)$
(or even the cochain groups $C^n(X; G) = \Hom(C_n(X), G)$) are harder to describe concretely.

\section{Cohomology of spaces is functorial}
We now check that the cohomology groups still exhibit the same nice functorial behavior.
First, let's categorize the previous results we had:

\begin{ques}
	Define $\catname{CoCmplx}$
	the category of cochain complexes.
\end{ques}

\begin{exercise}
	Interpret $\Hom(-,G)$ as a contravariant functor
	from \[ \Hom(-,G) \colon \catname{Cmplx}\op \to \catname{CoCmplx}. \]
	This means in particular that given a chain map $f \colon A_\bullet \to B_\bullet$,
	we naturally obtain a dual map $f^\vee \colon B^\bullet \to A^\bullet$.
\end{exercise}

\begin{ques}
	Interpret $H^n \colon \catname{CoCmplx} \to \catname{Grp}$ as a functor.
	Compose these to get a contravariant functor
	$H^n(-;G) \colon \catname{Cmplx}\op \to \catname{Grp}$.
\end{ques}

Then in exact analog to our result that $H_n \colon \catname{hTop} \to \catname{Grp}$ we have:
\begin{theorem}[$H^n (-;G): \catname{hTop}\op \to \catname{Grp}$]
	For every $n$, $H^n(-;G)$ is a contravariant functor
	from $\catname{hTop}\op$ to $\catname{Grp}$.
\end{theorem}
\begin{proof}
	The idea is to leverage the work we already did in constructing
	the prism operator earlier.
	First, we construct the entire sequence of functors
	from $\catname{Top}\op \to \catname{Grp}$:
	\begin{center}
	\begin{tikzcd}
		\catname{Top}\op \ar[rr, "C_\bullet"]
			&& \catname{Cmplx}\op \ar[rr, "\Hom(-;G)"]
			&& \catname{CoCmplx} \ar[rr, "H^n"]
			&& \catname{Grp} \\
		X \ar[dd, "f"', near start]
			&& C_\bullet(X) \ar[dd, "f_\sharp"', near start]
			&& C^\bullet(X;G)
			&& H^n(X;G) \\
			\quad \ar[rr, mapsto] &&
			\quad \ar[rr, mapsto] &&
			\quad \ar[rr, mapsto] &&
			\quad \\
		Y
			&& C_\bullet(Y)
			&& C^\bullet(Y;G) \ar[uu, "f_\sharp"', near start]
			&& H^n(Y;G). \ar[uu, "f^\ast"', near start]
	\end{tikzcd}
	\end{center}
	Here $f^\sharp = (f_\sharp)^\vee$, and $f^\ast$
	is the resulting induced map on homology groups of the cochain complex.

	So as before all we have to show is that $f \simeq g$,
	then $f^\ast = g^\ast$.
	Recall now that there is a prism operator such that
	$f_\sharp - g_\sharp = P \partial + \partial P$.
	If we apply the entire functor $\Hom(-;G)$ we get that
	$f^\sharp - g^\sharp = \delta P^\vee + P^\vee \delta$
	where $P^\vee \colon C^{n+1}(Y;G) \to C^n(X;G)$.
	So $f^\sharp$ and $g^\sharp$ are chain homotopic thus $f^\ast = g^\ast$.
\end{proof}


\section{Universal coefficient theorem}
We now wish to show that the cohomology groups are determined up to isomorphism
by the homology groups: given $H_n(A_\bullet)$, we can extract $H^n(A_\bullet; G)$.
This is achieved by the \emph{universal coefficient theorem}.
\begin{theorem}
	[Universal coefficient theorem]
	Let $A_\bullet$ be a chain complex of \emph{free} abelian groups,
	and let $G$ be another abelian group.
	Then there is a natural short exact sequence
	\[
		0 \to \Ext(H_{n-1}(A_\bullet), G) \to H^n(A_\bullet; G)
		\taking{h} \Hom(H_n(A_\bullet), G) \to 0. \]
	In addition, this exact sequence is \emph{split}
	so in particular
	\[ H^n(C_\bullet; G) \cong \Ext(H_{n-1}(A_\bullet), G)
		\oplus \Hom(H_n(A_\bullet), G). \]
\end{theorem}
Fortunately, in our case of interest, $A_\bullet$ is $C_\bullet(X)$
which is by definition free.

There are two things we need to explain, what the map $h$ is and the map $\Ext$ is.

It's not too hard to guess how \[ h \colon H^n(A_\bullet; G) \to \Hom(H_n(A_\bullet), G) \] is defined.
An element of $H^n(A_\bullet;G)$ is represented by a function which sends a cycle
in $A_n$ to an element of $G$.
The content of the theorem is to show that $h$ is surjective with kernel $\Ext(H_{n-1}(A_\bullet), G)$.

What about $\Ext$?
It turns out that $\Ext(-,G)$ is the so-called \vocab{Ext functor}, defined as follows.
Let $H$ be an abelian group, and consider a \vocab{free resolution} of $H$,
by which we mean an exact sequence
\[ \dots \taking{f_2} F_1 \taking{f_1} F_0 \taking{f_0} H \to 0 \]
with each $F_i$ free.
Then we can apply $\Hom(-,G)$ to get a cochain complex
\[ \dots \xleftarrow{f_2^\vee} \Hom(F_1, G) \xleftarrow{f_1^\vee}
	\Hom(F_0, G) \xleftarrow{f_0^\vee} \Hom(H,G) \leftarrow 0. \]
but \emph{this cochain complex need not be exact}
(in categorical terms, $\Hom(-,G)$ does not preserve exactness).
We define \[ \Ext(H,G) \defeq \ker(f_2^\vee) / \img(f_1^\vee) \]
and it's a theorem that this doesn't depend on the choice of the free resolution.
There's a lot of homological algebra that goes into this,
which I won't take the time to discuss;
but the upshot of the little bit that I did include is that the $\Ext$
functor is very easy to compute in practice, since
you can pick any free resolution you want and compute the above.

\begin{remark}
	You have seen a ``free resolution'' before in a disguised form ---
	in \Cref{sec:structure_thm}, we proved the structure theorem of finitely-generated modules
	over PID by writing any module $M$ as $R^{\oplus d}/K$, with both $R^{\oplus d}$ and $K$ free.
	This gives a free resolution
	\[ \dots \to 0 \to K \injto R^{\oplus d} \surjto M \to 0. \]

	Intuitively, you can think of the $\Ext$ functor as measuring the ``maps that should be there
	but aren't'' --- you will gradually gain some intuitions after seeing some
	examples.\footnote{Taken from \url{https://mathoverflow.net/a/679}.}
\end{remark}

%By ``natural'', we mean that if $f \colon A_\bullet \to B_\bullet$ is a chain map,
%then we obtain a commutative diagram
%\begin{diagram}
%	0 & \rTo & \Ext(H_{n-1}(A_\bullet), G) & \rTo
%		& H^n(A_\bullet;G) & \rTo & \Hom(H_n(A_\bullet), G) & \rTo & 0 \\
%	& & \uTo^{ \Ext(f_\ast, G) } & & \uTo^{f^\ast} & & \uTo^{\Hom(f_\ast, G)} & & \\
%	0 & \rTo & \Ext(H_{n-1}(B_\bullet), G) & \rTo
%		& H^n(A_\bullet;G) & \rTo & \Hom(H_n(B_\bullet), G) & \rTo & 0 \\
%\end{diagram}
%where $f_\ast$ is the induced arrow $H_n(A_\bullet) \to H_n(B_\bullet)$.

\begin{lemma}
	[Computing the $\Ext$ functor]
	For any abelian groups $G$, $H$, $H'$ we have
	\begin{enumerate}[(a)]
		\ii $\Ext(H \oplus H', G) = \Ext(H, G) \oplus \Ext(H', G)$.
		\ii $\Ext(H,G) = 0$ for $H$ free, and
		\ii $\Ext(\Zc n, G) = G / nG$.
	\end{enumerate}
\end{lemma}
\begin{proof}
	For (a), note that if $\dots \to F_1 \to F_0 \to H \to 0$
	and $\dots \to F_1' \to F_0' \to F_0' \to H' \to 0$ are free resolutions,
	then so is $F_1 \oplus F_1' \to F_0 \oplus F_0' \to H \oplus H' \to 0$.

	For (b), note that $0 \to H \to H \to 0$ is a free resolution.

	Part (c) follows by taking the free resolution
	\[ 0 \to \ZZ \taking{\times n} \ZZ \to \Zc n \to 0 \]
	and applying $\Hom(-,G)$ to it.
	\begin{ques}
		Finish the proof of (c) from here. \qedhere
	\end{ques}
\end{proof}

\begin{ques}
	Some $\Ext$ practice: compute
	$\Ext(\ZZ^{\oplus 2015}, G)$ and $\Ext(\Zc{30}, \Zc 4)$.
\end{ques}

\section{Explanation for universal coefficient theorem}

There is so much unexplained symbols and formulas in the previous chapter that may make you scream:
\begin{quote}
	I don't care if $\CP^2$ and $S^2 \vee S^4$ are distinct anymore! What are these spaces anyway?
\end{quote}
Nevertheless, it is not all that difficult. There are two key points to be read from the theorem:
\begin{itemize}
	\ii Even though $H_n(A_\bullet) = 0$, it is still possible for $H^n(A_\bullet; G) \neq 0$
	if $\Ext(H_{n-1}(A_\bullet), G) \neq 0$.

	In low-dimensional cases, we can actually visualize it --- \Cref{sec:visual_cohom_groups}
	does that for the Klein bottle.
	\ii $H^n(A_\bullet; G)$ is uniquely determined by $H_n(A_\bullet)$ and $G$, regardless of what
	$A_\bullet$ is, as long as each $A_n$ is free.
\end{itemize}

Which means: if you wish, you can forget about the formula in the universal coefficient theorem,
and use the cellular chain complex $\Cells_\bullet(X)$ to compute cohomology by:
\[ H^n(X; G) = \frac{\ker(\Hom(\Cells_n(X), G) \to \Hom(\Cells_{n+1}(X), G))}
{\img(\Hom(\Cells_{n-1}(X), G) \to \Hom(\Cells_{n}(X), G))}. \]
After all, the cellular chain complex and the singular chain complex are both free and have the same
homology groups, so by the universal coefficient theorem they must have the same cohomology groups.

Nevertheless, the formula of the universal coefficient theorem is desirable because, more often than
not, the chain complex $A_\bullet$ is more complicated than $H_\bullet(A_\bullet)$.

\begin{example}
	The Klein bottle's cellular chain complex has the following form:
	\[ \cdots \to \ZZ \taking{1 \mapsto (0, 2)} \ZZ^2 \taking {(a, b) \mapsto 0} \ZZ. \]
	The homology groups is:
	\[ H_2 = 0, H_1 = \ZZ \oplus \Zc{2}, H_0 = \ZZ. \]
	It's indeed simpler, but only marginally (there are $3$ generators instead of $4$, and we don't
	need to keep track of the maps)
	because cellular homology is already so efficient.
\end{example}

Where does the formula come from, again? You can think of it like this.
Because the universal coefficient theorem tells us that $H^\bullet(A_\bullet; G)$ only depends on
$H_\bullet(A_\bullet)$, if we're given $H_\bullet$, we just construct \emph{any} chain complex of
free abelian groups $A_\bullet$ and dualize it.

Assume $H_k = 0$ for every terms, except $H_{n-1}\neq 0$. Then, tautologically,
$H^n \cong \Ext(H_{n-1}; G)$ --- a free resolution \emph{is} a chain complex!

\begin{exercise}
	Verify this. (Hint: Starting from the exact sequence $Z_{n-1} \to H_{n-1} \to 0$.
	Can you extend it to a free resolution of $H_{n-1}$?)
\end{exercise}

Assume $H_k = 0$ for every terms, except $H_n \neq 0$. Then we can see $H^n \cong \Hom(H_n, G)$.

The universal coefficient theorem simply states that the choice of free resolution doesn't matter,
and that if the other terms can be nonzero, $H^n$ is the direct sum of the two groups in the two
cases above.

If you want, you can even prove the fact that the choice of free resolution does not matter yourself
--- it's a bit tricky, but not all that difficult. It boils down to the construction of maps
between the chain complexes (it's not difficult to ensure the diagram commutes, the groups are free
so we can send the basis wherever we want), and show the two free resolutions are chain homotopic.

\section{Example computation of cohomology groups}
\prototype{Possibly $H^n(S^m)$.}

The universal coefficient theorem gives us a direct way to compute
any cohomology groups, provided we know the homology ones.

\begin{example}
	[Cohomology groups of $S^m$]
	It is straightforward to compute $H^n(S^m)$ now:
	all the $\Ext$ terms vanish since $H_n(S^m)$ is always free,
	and hence we obtain that
	\[ H^n(S^m) \cong \Hom(H_n(S^m), G) \cong
		\begin{cases}
			G & n=m, n=0 \\
			0 & \text{otherwise}.
		\end{cases}
	\]
%	By UCT for reduced groups, we also have
%	\[ \wt H^n(S^m) \cong \Hom(\wt H_n(S^m), G) \cong
%		\begin{cases}
%			G & n=m \\
%			0 & \text{otherwise}.
%		\end{cases}
%	\]
%	since $\Hom(\ZZ, G)$.
\end{example}

\begin{example}
	[Cohomology groups of torus]
	This example has no nonzero $\Ext$ terms either,
	since this time $H^n(S^1 \times S^1)$ is always free.
	So we obtain
	\[ H^n(S^1 \times S^1) \cong \Hom(H_n(S^1 \times S^1), G). \]
	Since $H_n(S^1 \times S^1)$ is $\ZZ$, $\ZZ^{\oplus 2}$, $\ZZ$
	in dimensions $n=1,2,1$ we derive that
	\[
		H^n(S^1 \times S^1)
		\cong
		\begin{cases}
			G & n = 0,2 \\
			G^{\oplus 2} & n = 1.
		\end{cases}
	\]
\end{example}

From these examples one might notice that:
\begin{lemma}
	[$0$th and $1$th cohomology groups are just duals]
	For $n = 0$ and $n = 1$, we have
	\[ H^n(X;G) \cong \Hom(H_n(X), G). \]
\end{lemma}
\begin{proof}
	It's already been shown for $n=0$.
	For $n=1$, notice that $H_0(X)$ is free,
	so the $\Ext$ term vanishes.
\end{proof}

\begin{example}
	[Cohomology groups of Klein bottle]
	This example will actually have $\Ext$ term.
	Recall from \Cref{ex:homology_klein} that if $K$ is a Klein Bottle then its homology groups are
	$\ZZ$ in dimension $n=0$ and $\ZZ \oplus \Zc 2$ in $n=1$, and $0$ elsewhere.

	For $n=0$, we again just have $H^0(K;G) \cong \Hom(\ZZ, G) \cong G$.
	For $n=1$, the $\Ext$ term is $\Ext(H_0(K), G) \cong \Ext(\ZZ, G) = 0$
	so \[ H^1(K;G) \cong \Hom(\ZZ \oplus \Zc2, G) \cong G \oplus \Hom(\Zc2, G). \]
	We have that $\Hom(\Zc2,G)$ is the subgroup
	of elements of order $2$ in $G$ (and $0 \in G$).

	But for $n=2$, we have our first interesting $\Ext$ group:
	the exact sequence is
	\[ 0 \to \Ext(\ZZ \oplus \Zc 2, G) \to H^2(X;G) \to \underbrace{H_2(X)}_{=0} \to 0. \]
	Thus, we have
	\[ H^2(X;G) \cong \left( \Ext(\ZZ,G) \oplus \Ext(\Zc2,G) \right) \oplus 0
		\cong G/2G. \]
	All the higher groups vanish.
	In summary:
	\[
		H^n(X;G) \cong
		\begin{cases}
			G & n = 0 \\
			G \oplus \Hom(\Zc2, G) & n = 1 \\
			G/2G & n = 2 \\
			0 & n \ge 3.
		\end{cases}
	\]
\end{example}

\section{Visualization of cohomology groups}
\label{sec:visual_cohom_groups}

We try to make sense of $C^n(X; G)$ and $H^n(X; G)$, for higher values of $n$.

As above, $C_n(X; G)$ is the free abelian group on $n$-simplices on $X$, so an element
$f \in C^n(X; G)$ is a function that takes each $n$-simplex to an element of $G$
(and extends linearly to all of $C_n(X; G)$).

This assignment of value need not have any nice properties --- recall that a $n$-simplex is simply
a (continuous) map $\sigma \colon \Delta^n \to X$, and different maps $\sigma_1$ and
$\sigma_2$ are considered different even though $\img \sigma_1 = \img \sigma_2$.
In particular,
\begin{itemize}
	\ii If $[v_0, v_1, v_2]$ is a singular simplex,
	it need not be the case that $f([v_0, v_1, v_2]) + f([v_0, v_2, v_1]) = 0$.
	\ii A singular $n$-simplex ($n \geq 1$)
	with image contained in a point need not be mapped to $0$ by $f$.
\end{itemize}

But it \emph{does not matter} that elements of $C_n(X)$ aren't this nice!
We will see below why this is the case.

In the homology case (\Cref{def:cycle_and_boundary}), we defined:
\begin{align*}
	Z_n(X) &\defeq \ker\left( C_{n}(X) \taking\partial C_{n-1}(X) \right), \\
	B_n(X) &\defeq \img \left( C_{n+1}(X) \taking\partial C_n(X) \right), \\
	H_n(X) &\defeq Z_n(X)/B_n(X).
\end{align*}
Elements of $Z_n(X)$ and $B_n(X)$ are called cycles and boundaries respectively,
with the obvious geometrical interpretation.

So,
\[
	H_n(X) = \frac{\text{$n$-cycles}}{\text{$n$-boundaries}}.
\]

For the current section, we will temporarily define:
\begin{align*}
	Z^n(X; G) &\defeq \ker\left( C^n(X; G) \taking\delta C^{n+1}(X; G) \right), \\
	B^n(X; G) &\defeq \img\left( C^{n-1}(X; G) \taking\delta C^n(X; G) \right), \\
	H^n(X; G) &\defeq Z^n(X; G)/B^n(X; G).
\end{align*}

For this section, we will call elements of $Z^n(X; G)$ the \vocab{cocycles}
and elements of $B^n(X; G)$ the \vocab{coboundaries} respectively.
Once again,
\[ H^n(X; G) = \frac{\text{$n$-cocycles}}{\text{$n$-coboundaries}}. \]

It's less clear geometrically why the elements are named as above, but
if we assume the group $G$ is a \emph{field} (where the group operation is the addition
operation in the field), then\footnote{Refer to
\url{https://math.stackexchange.com/q/4712676}.} we have:
\begin{itemize}
	\ii a $n$-cocycle is a map that sends every $n$-boundary to $0 \in G$;
	\ii a $n$-coboundary is a map that sends every $n$-cycle to $0 \in G$.
\end{itemize}

The first statement is clear (definition chasing), the second statement is only generally true in
one direction (that a coboundary sends every cycle to $0$; but a map that sends every cycle to $0$
need not be a coboundary --- we will see this later on with the Klein bottle example).

Let us see what a $n$-cocycle must look like. First,
\begin{moral}
	Homotopic chains with the same boundary are mapped to the same value by cocycles.
\end{moral}
We defined what it means for two $k$-simplices to be homotopic in \Cref{sec:higher_homotopy_grps}
--- in the current situation, we require in addition that the boundaries are always fixed.

For instance, the blue and the orange $1$-simplices below are homotopic, but not the red
$1$-simplex.
\begin{center}
\begin{asy}
	size(4cm);
	filldraw(scale(8, 6)*shift(-0.5, -0.5)*unitsquare, yellow+opacity(0.1));
	pair A = (-3, 0);
	pair B = (3, 0);
	draw(A..(-2,0.5)..(0,2)..(1,1.2)..B, red);
	draw(A--(-1,-1)--(2,-1)--B, blue);
	draw(A--(-1,-2)--(2,-2)--B, orange);
	dot("$p$", A, align=W);
	dot("$q$", B, align=E);
	filldraw(scale(0.5)*unitcircle, grey, black);
\end{asy}
\end{center}

Proof is not difficult --- you just need to show that the difference between two homotopic
$k$-simplices is the boundary of something (their interior!), and write the interior as the
sum of some $k+1$-simplices. (Hint: The easiest way is actually to write the interior as the
difference of two $k+1$-simplices instead, and be careful of vertex ordering issues.)
\begin{exercise}
	Finish the proof.
\end{exercise}

A typical $1$-cocycle might look something like this, where each arrow is labeled with the value
assigned to that $1$-simplex. Remember that a cycle must be mapped to $0$.
\begin{center}
\begin{asy}
	size(4cm);
	filldraw(scale(4)*unitsquare, yellow+opacity(0.1));
	draw((1.5, 1)--(1, 3), L=Label("$-3$", align=SW), Arrow, DotMargin);
	draw((1, 3)--(3, 2), L=Label("$1$", align=NE), Arrow, DotMargin);
	draw((3, 2){dir(-170)}..(1.5, 1), L=Label("$2$"), Arrow, DotMargin);
	draw((3, 2){dir(-120)}..(1.5, 1), L=Label("$2$", align=SE), Arrow, DotMargin);
\end{asy}
\end{center}

Now, the next observation is that:
\begin{moral}
	If we only consider cocycles modulo coboundaries, we basically only care about values assigned
	to the cycles.
\end{moral}
Why?
Remember that a $k$-coboundary is the $\delta$ of some $(k-1)$-cochain. So, given this $0$-cochain:
\begin{center}
\begin{asy}
	size(3cm);
	filldraw(scale(4)*unitsquare, yellow+opacity(0.1));
	dot("$1$", (1.5, 2));
\end{asy}
\end{center}
Its $\delta$ would look something like this:
\begin{center}
\begin{asy}
	size(3cm);
	filldraw(scale(4)*unitsquare, yellow+opacity(0.1));
	pair A=(1.5, 2);
	draw(A+dir(45)*1.5--A, Arrow, DotMargin, L=Label("$1$"));
	draw(A+dir(120)*1.5--A, Arrow, DotMargin, L=Label("$1$"));
	draw(A+dir(-160)*1--A, Arrow, DotMargin, L=Label("$1$"));
	draw(A--A+dir(-60)*2, red, Arrow, DotMargin, L=Label("$-1$"));
	dot(A);
\end{asy}
\end{center}

So, roughly speaking,
\begin{moral}
	By adding or subtracting a coboundary to a given cochain, we can adjust the value assigned to
	most chains however we want.
\end{moral}
I said ``most chains'' because, if the chains form a \emph{cycle}, adding a coboundary won't let us
change its assigned value.

Fortunately,
\begin{itemize}
	\ii Cycles that are \emph{boundaries} always get assigned the value $0$.
	\ii Homotopic cycles get assigned the same value.

	As a generalization, in fact, cycles that are homologous (i.e. they get mapped to
	the same value under the map $Z_k(X) \surjto H_k(X)$) are assigned the same value.
\end{itemize}

Therefore,
\begin{moral}
	Knowing the value of a cocycle on each ``cycle modulo boundary'' almost determines that cocycle,
	modulo coboundaries.
\end{moral}
In symbols: $H^n(X; G)$ is ``almost isomorphic'' to $\Hom(H_n(X), G)$.

In other words, a cocycle modulo coboundary can be ``evaluated'' on a cycle modulo boundary.

This is precisely what the universal coefficient theorem states, although it says something more:
the ``error term'' is exactly $\Ext(H_{n-1}(X), G)$.

Why would the error term exist? We had an example above, computing $H^2(K; G)$ for $K$ the Klein
bottle. Let us work through it geometrically, assume $G = \ZZ$ for now.

A typical $2$-cochain $f \in C^2(K; \ZZ)$ may look something like this.
(Only value assigned to a few $2$-simplices is depicted, there are too many $2$-simplices for us to
draw.)
\begin{center}
\begin{asy}
	size(0); unitsize(2cm);
	fill(unitsquare, yellow+opacity(0.2));
	pair C = (0,0);
	pair B = (1,0);
	pair A = (1,1);
	pair D = (0,1);
	draw(A--B, red, MidArrow);
	draw(C--B, blue, MidArrow);
	draw(D--C, red, MidArrow, L=Label("$f = {}$", black));
	draw(A--D, blue, MidArrow);
	draw(A--C);
	label("$1$", (A+B+C)/3);
	label("$2$", (A+D+C)/3);
\end{asy}
\end{center}
A coboundary may look like this --- identical to the situation above, the value assigned to
particular simplex doesn't matter, we can ``transfer'' the assigned value between the two simplices
by adding a coboundary.
\begin{center}
\begin{asy}
	size(0); unitsize(2cm);
	fill(unitsquare, yellow+opacity(0.2));
	pair C = (0,0);
	pair B = (1,0);
	pair A = (1,1);
	pair D = (0,1);
	draw(A--B, red, MidArrow);
	draw(C--B, blue, MidArrow);
	draw(D--C, red, MidArrow);
	draw(A--D, blue, MidArrow);
	draw(A--C, Arrow, L="$1$");

	A+=(2, 0);
	B+=(2, 0);
	C+=(2, 0);
	D+=(2, 0);
	draw((1.1, 0.5)--(1.9, 0.5), Arrow, L="$\delta$");
	fill(shift(2, 0)*unitsquare, yellow+opacity(0.2));
	draw(A--B, red, MidArrow);
	draw(C--B, blue, MidArrow);
	draw(D--C, red, MidArrow);
	draw(A--D, blue, MidArrow);
	draw(A--C);

	label("$1$", (A+B+C)/3);
	label("$-1$", (A+D+C)/3);
\end{asy}
\end{center}

So, we may just say that the value assigned to the whole surface of the Klein bottle is $3$ ---
formally, let $e^2_K \in C_2(K)$ be the sum of the two $2$-simplices above, we can write $f(e^2_K) =
3$.
However:
\begin{center}
\begin{asy}
	size(0); unitsize(2cm);
	fill(unitsquare, yellow+opacity(0.2));
	pair C = (0,0);
	pair B = (1,0);
	pair A = (1,1);
	pair D = (0,1);
	draw(A--B, red, MidArrow);
	draw(C--B, blue, MidArrow, L="$1$");
	draw(D--C, red, MidArrow, L=Label("$g = {}$", black));
	draw(A--D, blue, MidArrow, L="$1$");
	draw(A--C);

	A+=(2, 0);
	B+=(2, 0);
	C+=(2, 0);
	D+=(2, 0);
	draw((1.1, 0.5)--(1.9, 0.5), Arrow, L="$\delta$");
	fill(shift(2, 0)*unitsquare, yellow+opacity(0.2));
	draw(A--B, red, MidArrow);
	draw(C--B, blue, MidArrow);
	draw(D--C, red, MidArrow);
	draw(A--D, blue, MidArrow);
	draw(A--C);

	label("$1$", (A+B+C)/3);
	label("$1$", (A+D+C)/3);
\end{asy}
\end{center}

The boundary of the $2$-chain corresponding to the whole surface of the Klein bottle is $2$ times
the blue edge, so $\delta$ of the $1$-cochain whose value on the blue edge is $1$
will assign the value $2$ to $e^2_K$.

In symbols: let $e^1_b \in C_1(K)$ be the blue edge, pick $g \in C^1(K; \ZZ)$ such that
$g(e^1_b) = 1$, then $\delta(g)(e^2_K) = 2$.
Even though $e^2_K$ is not a cycle, we still need to care about its assigned value modulo $2$!
Because adding or subtracting the coboundary $\delta(g)$ can only adjust its values in increments
of $2$.

Therefore,
\begin{moral}
	If the region $e^k \in C_k(X)$ has a boundary $\partial e^k \in C_{k-1}(X)$ divisible by $n$,
	then we cares about the value assigned to $e^k$, modulo $n$.
\end{moral}

This explains where the error term $\Ext(H_{n-1}(X), G)$ comes from.

We have another comparison with de Rham cohomology in \Cref{sec:de_rham_cohom} ---
in that case, the group $G$ is a field, $\RR$, so $\Ext(H_{n-1}(X), G)$ is always zero.

\section{Relative cohomology groups}
One can also define relative cohomology groups in the obvious way:
dualize the chain complex
\[ \dots \taking\partial C_1(X,A) \taking\partial C_0(X,A) \to 0 \]
to obtain a cochain complex
\[
	\dots \xleftarrow\delta C^1(X,A;G) \xleftarrow\delta C^0(X,A;G)
	\leftarrow 0.
\]
We can take the cohomology groups of this.
\begin{definition}
	The groups thus obtained are the \vocab{relative cohomology groups}
	are denoted $H^n(X,A;G)$.
\end{definition}

In addition, we can define reduced cohomology groups as well.
One way to do it is to take the augmented singular chain complex
\[ \dots \taking\partial C_1(X) \taking\partial C_0(X) \taking\eps \ZZ \to 0 \]
and dualize it to obtain
\[
	\dots \xleftarrow\delta C^1(X;G) \xleftarrow\delta C^0(X;G)
	\xleftarrow{\eps^\vee} \underbrace{\Hom(\ZZ, G)}_{\cong G}
	\leftarrow 0.
\]
Since the $\ZZ$ we add is also free,
the universal coefficient theorem still applies.
So this will give us reduced cohomology groups.

However, since we already defined the relative cohomology groups,
it is easiest to simply define:
\begin{definition}
	The \vocab{reduced cohomology groups} of a nonempty space $X$,
	denoted $\wt H^n(X; G)$,
	are defined to be $H^n(X, \{\ast\} ; G)$
	for some point $\ast \in X$.
\end{definition}


\section\problemhead
\begin{sproblem}
	[Wedge product cohomology]
	For any $G$ and $n$ we have
	\[
		\wt H^n(X \vee Y; G)
		\cong
		\wt H^n(X; G) \oplus \wt H^n(Y; G).
	\]
\end{sproblem}

\begin{dproblem}
	Prove that for a field $F$ of characteristic zero and a space $X$
	with finitely generated homology groups:
	\[ H^k(X, F) \cong \left( H_k(X) \right)^\vee.  \]
	Thus over fields cohomology is the dual of homology.
\end{dproblem}

\begin{problem}[$\Zc2$-cohomology of $\RP^n$]
	Prove that
	\[
		H^m(\RP^n, \Zc2)
		\cong
		\begin{cases}
			\ZZ & \text{$m=0$, or $m$ is odd and $m=n$} \\
			\Zc2 & \text{$0 < m < n$ and $m$ is odd} \\
			0 & \text{otherwise}.
		\end{cases}
	\]
\end{problem}
